package com.janj.service;

import com.janj.bean.Student;
import com.janj.dao.StudentMapper;
import com.janj.util.MyBatisUitls;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;

//实现类
public class StudentServiceimpl implements StudentService {

    @Override
    public List<Student> selectAll() {
        //1.获取到执行者
        SqlSession session = MyBatisUitls.getSQLSession();

        //2.执行SQL --> 找到StudentMapper
                StudentMapper mapper = session.getMapper(StudentMapper.class);

        //3.调用接口的方法
        List<Student> array = mapper.selectAll();

        //4.释放资源
        MyBatisUitls.close();
        return array ;
    }

    @Override
    public List<Student> selectMoreFactorDiffer(HashMap<String, String> map) {
        //1.获取到执行者
        SqlSession session = MyBatisUitls.getSQLSession();

        //2.执行SQL --> 找到 StudentMapper
        StudentMapper mapper = session.getMapper(StudentMapper.class);

        //3.调用接口方法
        List<Student> array = mapper.selectMoreFactorDiffer(map);

        //4.释放资源
        MyBatisUitls.close();

        return array;
    }
}
